#include<iostream>
using namespace std;
int nm(int a,int b)
{
	if(a%b==0) return b;
	else return nm(b,a%b);
}
int main()
{
	int n,m,k;
	//if(m>n){k=n;n=m;m=k;}
	cin>>n>>m;
	cout<<nm(n,m);
	while(1);
	return 0;
}
